package com.smart.register.service.redis.utils;

import redis.clients.jedis.Jedis;

import com.smart.register.service.redis.RedisCallback;
import com.smart.register.service.redis.ReidsTemplate;


public class RedisUtils {
	
	private static final ReidsTemplate reidsTemplate = new ReidsTemplate();
	
	public static String setValue(final String key, final String value){
		return reidsTemplate.execute(new RedisCallback<String>() {
			@Override
			public String doInRedis(Jedis conn) throws Exception {
				return conn.set(key, value);
			}
		});
	}
	
	public static String getValue(final String key, final String value){
		return reidsTemplate.execute(new RedisCallback<String>() {
			@Override
			public String doInRedis(Jedis conn) throws Exception {
				return conn.get(key);
			}
		});
	}
	
	public static Long delete(final String key){
		return reidsTemplate.execute(new RedisCallback<Long>() {
			@Override
			public Long doInRedis(Jedis conn) throws Exception {
				return conn.del(key);
			}
		});
	}
}
